#!/bin/sh /etc/rc.common
# Copyright (c) 2011-2015 OpenWrt.org

START=30

start(){
  enable=$(uci get sfe.config.enabled 2>/dev/null)
  wifi=$(uci get sfe.config.wifi)
  ipv6=$(uci get sfe.config.ipv6)
	if [ $enable -eq 1 ]; then
      echo "enable"
      ! (lsmod | grep fast_classifier >/dev/null) && (modprobe fast_classifier)
      if [ $wifi -eq 1 ] ;  then
       echo "wifi"
       echo 1 > /sys/fast_classifier/skip_to_bridge_ingress
      else
       echo "no wifi"
       echo 0 > /sys/fast_classifier/skip_to_bridge_ingress
      fi
      if [ $ipv6 -eq 1 ];  then
        echo "ipv6"
        sfe_ipv6=$(cat /sys/sfe_ipv6/debug_dev)
        [ -f /dev/sfe_ipv6 ] && mknod /dev/sfe_ipv6 c $sfe_ipv6 0
      else
        echo "no ipv6"
        rm -f /dev/sfe_ipv6
      fi
  fi
}

stop(){
    enable=$(uci get sfe.config.enabled 2>/dev/null)
	  [ $enable -ne 1 ] && rmmod fast_classifier
	  echo "stop"
}

restart(){
	  stop
	  start
}


